import { defineStore } from 'pinia'
export const userListStore = defineStore('user', {
    state: () => ({
        userList: [
            {
                "name": "zhangsan",
                "password": "123",
                "id": "000001",
                "imgUrl": "http://www.dell-lee.com/imgs/vue3/orange.png",
                "list": [
                    {
                        "title": "红包",
                        "content": 218
                    },
                    {
                        "title": "优惠劵",
                        "content": "12张"
                    },
                    {
                        "title": "红豆",
                        "content": 88
                    },
                    {
                        "title": "白条",
                        "content": 1000
                    }
                ],
                "addressList": [
                    {
                        "name": "小慕",
                        "phone": 18611111111,
                        "address_text": "北京 海淀区西三环北路2号院北京理工大学国防科技园2号楼10号"
                    },
                    {
                        "name": "小可",
                        "phone": 18622222222,
                        "address_text": "北京 朝阳区北京工业大学3号楼303"
                    }
                ],
                "currentAddress": null
            },
            {
                "name": "admin",
                "password": "123",
                "id": "000002",
                "imgUrl": "http://www.dell-lee.com/imgs/vue3/orange.png",
                "list": [
                    {
                        "title": "红包",
                        "content": 22
                    },
                    {
                        "title": "优惠劵",
                        "content": "7张"
                    },
                    {
                        "title": "红豆",
                        "content": 120
                    },
                    {
                        "title": "白条",
                        "content": 2000
                    }
                ],
                "addressList": [],
                "currrentAddress": null
            }
        ]
    }),
    actions: {
        updateadd(add) {
            const name = add.name;
            const phone = add.phone;
            const address_text = add.province + add.text + add.number;
            this.userList[0].addressList.push({
                name: name,
                phone: phone,
                address_text: address_text
            });
        }
    }
})
